<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<form action="" id="login-form">
    <input type="text" name="username"> <br>
    <input type="password" name="password">
    <button type="button" onclick="submitHandler()">登录</button>
</form>

<!--导入jquery-->
<script src="/static/plugins/jquery.min.js"></script>
<script src="/static/plugins/layer/layer.js"></script>
<script>

    <!--提交表单-->
    function submitHandler() {

        var url = "/login";
        var formObj = $("#login-form").serialize();
        $.post(url, formObj, function (resp) {

            if (resp.code == 200) {
                layer.msg("登录成功");
            }else{
                layer.msg(resp.msg);
            }
        });
    }
</script>

</body>
</html>